package com.android.monee.data.model;

import java.util.Date;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import com.android.monee.data.access.IdNClone;

public class Budget implements IdNClone<Integer, Budget> {

	public enum BudgetState {
		RUNNING, PAUSED
	};

	private Integer id;
	private String name;
	private float totalAmount;
	private float initialAmount;
	private Date begin;
	private Date term;
	protected BudgetState state;

	public Budget() {
	}

	public Budget(Budget budget) {
		this.id = budget.getId();
		this.name = budget.getName();
		this.totalAmount = budget.getTotalAmount();
		this.initialAmount = budget.getInitialAmount();
		this.begin = budget.getBegin();
		this.term = budget.getTerm();
		this.state = budget.getState();
	}

	@Override
	public Budget clone() {
		Budget budget = null;

		try {
			budget = (Budget) super.clone();
			if(begin != null)
				budget.begin = (Date) begin.clone();
			if(budget.term != null)
				budget.term = (Date) term.clone();

		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return budget;
	}

	@Override
	public boolean equals(Object obj){
        return EqualsBuilder.reflectionEquals(this, obj);
	}
	
	@Override
	public int hashCode(){
		return HashCodeBuilder.reflectionHashCode(this);
	}
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public float getTotalAmount() {
		return totalAmount;
	}

	public void setTotalAmount(float totalAmount) {
		this.totalAmount = totalAmount;
	}

	public float getInitialAmount() {
		return initialAmount;
	}

	public void setInitialAmount(float provAmount) {
		this.initialAmount = provAmount;
	}

	public Date getBegin() {
		return begin;
	}

	public void setBegin(Date begin) {
		this.begin = begin;
	}

	public Date getTerm() {
		return term;
	}

	public void setTerm(Date term) {
		this.term = term;
	}

	public BudgetState getState() {
		return state;
	}

	public void setState(BudgetState state) {
		this.state = state;
	}
}
